package com.link2room.rodimus.nmsrunner;

import com.aliyun.mns.model.Message;
import com.link2room.common.mns.Worker;
import com.link2room.common.util.JacksonUtil;
import com.link2room.rodimus.dto.param.inside.SalesmanInComeDetailInsideParamDto;
import com.link2room.rodimus.facade.ISalesmaManagerFacadeService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Created by LN on 2017/2/20.
 */
@Component("salemanAwardMemberRunner")
public class SalemanAwardMemberRunnerImpl implements Worker{
    @Resource
    private ISalesmaManagerFacadeService salesmanManagerFacadeService;
    @Override
    public boolean exec(Message message) throws Exception {
        SalesmanInComeDetailInsideParamDto paramDto = JacksonUtil.jsonToBean(message.getMessageBody(),SalesmanInComeDetailInsideParamDto.class);
        try {
            if(message.getDequeueCount()<=3){
                salesmanManagerFacadeService.paySalesmanAwardMemberStep(paramDto);
            }
        }catch (Exception e){
            return false;
        }
        return true;
    }
}
